using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Tilemaps;

public class GameResources : MonoBehaviour
{
    private static GameResources instance;

    public static GameResources Instance
    {
        get
        {
            if (instance == null)
            {
                instance = Resources.Load<GameResources>("GameResources");
            }

            return instance;
        }
    }

    #region Header DUNGEON

    [Space(10)]
    [Header("地牢")]

    #endregion

    #region Tooltip

    [Tooltip("填充地牢 RoomNodeTypeListSO")]

    #endregion

    public RoomNodeTypeListSO roomNodeTypeList;
    
    #region PLAYER SELECTION
    [Space(10)]
    [Header("角色选择")]
    #endregion PLAYER SELECTION
    #region Tooltip
    [Tooltip("PlayerSelection 预制件")]
    #endregion Tooltip
    public GameObject playerSelectionPrefab;

    #region Header PLAYER

    [Space(10)]
    [Header("玩家")]

    #endregion Header PLAYER
    
    #region Tooltip
    [Tooltip("玩家详细信息列表 - 使用 playerdetails 可编写脚本的对象填充列表")]
    #endregion Tooltip
    public List<PlayerDetailsSO> playerDetailsList;

    #region Tooltip

    [Tooltip("当前播放器可编写脚本的对象 - 用于在场景之间引用当前播放器")]

    #endregion Tooltip

    public CurrentPlayerSO currentPlayer;

    #region Header MUSIC
    [Space(10)]
    [Header("音乐")]
    #endregion Header MUSIC
    #region Tooltip
    [Tooltip("填充音乐主混音器组")]
    #endregion
    public AudioMixerGroup musicMasterMixerGroup;
    #region Tooltip
    [Tooltip("主菜单音乐脚本化对象")]
    #endregion Tooltip
    public MusicTrackSO mainMenuMusic;
    #region Tooltip
    [Tooltip("音乐完整快照")]
    #endregion Tooltip
    public AudioMixerSnapshot musicOnFullSnapshot;
    #region Tooltip
    [Tooltip("音乐低快照")]
    #endregion Tooltip
    public AudioMixerSnapshot musicLowSnapshot;
    #region Tooltip
    [Tooltip("音乐关闭快照")]
    #endregion Tooltip
    public AudioMixerSnapshot musicOffSnapshot;

    #region Header SOUNDS

    [Space(10)]
    [Header("声音")]

    #endregion Header

    #region Tooltip

    [Tooltip("填充声音主混音器组")]

    #endregion

    public AudioMixerGroup soundsMasterMixerGroup;
    
    #region Tooltip
    [Tooltip("开门、关门、音效")]
    #endregion Tooltip
    public SoundEffectSO doorOpenCloseSoundEffect;
    #region Tooltip
    [Tooltip("填充表格翻转音效")]
    #endregion
    public SoundEffectSO tableFlip;
    #region Tooltip
    [Tooltip("填充打开宝箱的声音效果")]
    #endregion
    public SoundEffectSO chestOpen;
    #region Tooltip
    [Tooltip("填充健康拾音效果")]
    #endregion
    public SoundEffectSO healthPickup;
    #region Tooltip
    [Tooltip("填充武器拾取音效")]
    #endregion
    public SoundEffectSO weaponPickup;
    #region Tooltip
    [Tooltip("填充弹药拾取音效")]
    #endregion
    public SoundEffectSO ammoPickup;

    #region Header MATERIALS

    [Space(10)]
    [Header("材料")]

    #endregion

    #region Tooltip

    [Tooltip("调暗材料")]

    #endregion

    public Material dimmedMaterial;

    #region Tooltip

    [Tooltip("Sprite-lit-default 材质")]

    #endregion

    public Material litMaterial;

    #region Tooltip

    [Tooltip("填充 Variable Lit 着色器")]

    #endregion

    public Shader variableLitShader;
    #region Tooltip
    [Tooltip("使用 Materialize 着色器填充")]
    #endregion
    public Shader materializeShader;
    
    #region Header SPECIAL TILEMAP TILES
    [Space(10)]
    [Header("特殊瓦片地图瓦片")]
    #endregion Header SPECIAL TILEMAP TILES
    #region Tooltip
    [Tooltip("敌人可以导航到的碰撞图块")]
    #endregion Tooltip
    public TileBase[] enemyUnwalkableCollisionTilesArray;
    #region Tooltip
    [Tooltip("敌人导航的首选路径图块")]
    #endregion Tooltip
    public TileBase preferredEnemyPathTile;

    #region Header UI

    [Space(10)]
    [Header("UI")]

    #endregion
    
    #region Tooltip
    [Tooltip("填充心形图像预制件")]
    #endregion
    public GameObject heartPrefab;

    #region Tooltip

    [Tooltip("填充弹药图标预制件")]

    #endregion
    
    public GameObject ammoIconPrefab;
    #region Tooltip
    [Tooltip("分数预制件")]
    #endregion
    public GameObject scorePrefab;
    
    #region Header CHESTS
    [Space(10)]
    [Header("箱子")]
    #endregion
    #region Tooltip
    [Tooltip("宝箱物品预制件")]
    #endregion
    public GameObject chestItemPrefab;
    #region Tooltip
    [Tooltip("填充心形图标精灵")]
    #endregion
    public Sprite heartIcon;
    #region Tooltip
    [Tooltip("填充子弹图标精灵")]
    #endregion
    public Sprite bulletIcon;
    
    #region Header MINIMAP
    [Space(10)]
    [Header("小地图")]
    #endregion
    #region Tooltip
    [Tooltip("小地图骷髅头预制件")]
    #endregion
    public GameObject minimapSkullPrefab;

    #region Validation

#if UNITY_EDITOR
    // 验证输入的可编写脚本的对象详细信息
    private void OnValidate()
    {
        HelperUtilities.ValidateCheckNullValue(this, nameof(roomNodeTypeList), roomNodeTypeList);
        HelperUtilities.ValidateCheckNullValue(this, nameof(playerSelectionPrefab), playerSelectionPrefab);
        HelperUtilities.ValidateCheckEnumerableValues(this, nameof(playerDetailsList), playerDetailsList);
        HelperUtilities.ValidateCheckNullValue(this, nameof(currentPlayer), currentPlayer);
        HelperUtilities.ValidateCheckNullValue(this, nameof(mainMenuMusic), mainMenuMusic);
        HelperUtilities.ValidateCheckNullValue(this, nameof(soundsMasterMixerGroup), soundsMasterMixerGroup);
        HelperUtilities.ValidateCheckNullValue(this, nameof(doorOpenCloseSoundEffect), doorOpenCloseSoundEffect);
        HelperUtilities.ValidateCheckNullValue(this, nameof(tableFlip), tableFlip);
        HelperUtilities.ValidateCheckNullValue(this, nameof(chestOpen), chestOpen);
        HelperUtilities.ValidateCheckNullValue(this, nameof(healthPickup), healthPickup);
        HelperUtilities.ValidateCheckNullValue(this, nameof(ammoPickup), ammoPickup);
        HelperUtilities.ValidateCheckNullValue(this, nameof(weaponPickup), weaponPickup);
        HelperUtilities.ValidateCheckNullValue(this, nameof(litMaterial), litMaterial);
        HelperUtilities.ValidateCheckNullValue(this, nameof(dimmedMaterial), dimmedMaterial);
        HelperUtilities.ValidateCheckNullValue(this, nameof(variableLitShader), variableLitShader);
        HelperUtilities.ValidateCheckNullValue(this, nameof(materializeShader), materializeShader);
        HelperUtilities.ValidateCheckEnumerableValues(this, nameof(enemyUnwalkableCollisionTilesArray), enemyUnwalkableCollisionTilesArray);
        HelperUtilities.ValidateCheckNullValue(this, nameof(preferredEnemyPathTile), preferredEnemyPathTile);
        HelperUtilities.ValidateCheckNullValue(this, nameof(musicMasterMixerGroup), musicMasterMixerGroup);
        HelperUtilities.ValidateCheckNullValue(this, nameof(musicOnFullSnapshot), musicOnFullSnapshot);
        HelperUtilities.ValidateCheckNullValue(this, nameof(musicLowSnapshot), musicLowSnapshot);
        HelperUtilities.ValidateCheckNullValue(this, nameof(musicOffSnapshot), musicOffSnapshot); 
        HelperUtilities.ValidateCheckNullValue(this, nameof(heartPrefab), heartPrefab);
        HelperUtilities.ValidateCheckNullValue(this, nameof(ammoIconPrefab), ammoIconPrefab);
        HelperUtilities.ValidateCheckNullValue(this, nameof(scorePrefab), scorePrefab);
        HelperUtilities.ValidateCheckNullValue(this, nameof(chestItemPrefab), chestItemPrefab);
        HelperUtilities.ValidateCheckNullValue(this, nameof(heartIcon), heartIcon);
        HelperUtilities.ValidateCheckNullValue(this, nameof(bulletIcon), bulletIcon);
        HelperUtilities.ValidateCheckNullValue(this, nameof(minimapSkullPrefab), minimapSkullPrefab);
    }

#endif

    #endregion
}